home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
keyb
/
gold22.zip
/
GOLD.ASM
< prev
next >
Wrap
Assembly Source File
|
1992-02-16
|
18KB
|
593 lines
PAGE 64,132
TITLE GOLD key from NUMLOCK
NAME GOLD
;
; This program maps the NUM LOCK key (scan code 45H) to F1 (scan code 3BH)
; for use with Kermit emulating a DEC VT100.
;
; Version 2.2 - February 1992
; Added safety checks to installation code
; Version 2.1 - June 1991
; Changed default multiplex ID to 09FH (was 0DCH) to avoid
; problems with some versions of the KEYB program.
; Version 2.0 - March 1991
; SHIFT and NUM LOCK acts as normal NUM LOCK
; ALT and NUM LOCK inverts current GOLD status
; Fix for problem with some clone BIOSes
; Fix non-detection of BIOS intercept support
; Use INT 09H if interrupt intercept not available
;
; Bob Eager
; rde@ukc.ac.uk USENET (preferred over ibmpcug)
; rde@ibmpcug.co.uk USENET
; 100016,2770 CompuServe
; +44 227 367270 Telephone
;
; You may distribute this program freely as long as all of the files that
; make up the package (see the documentation file) are kept with it (including
; this source file) and you don't try to make money from it either by selling
; it directly or incorporating it into a product you sell.
;
; Values for exit status:
;
; 0 - success
; 1 - could not install program
; 2 - no BIOS support present
; 3 - unsupported DOS version (< 3.0)
; 4 - invalid parameter
;
; Constants
; ---------
;
CR = 0DH ; Carriage return
LF = 0AH ; Linefeed
TAB = 09H ; Tab
;
ID = 0DCH ; Multiplex ID
;
CSEG SEGMENT BYTE PUBLIC 'CODE'
;
$BEGIN EQU $
;
ORG 0100H
;
ASSUME CS:CSEG,DS:CSEG,ES:CSEG,SS:CSEG
;
SUBTTL Data areas
PAGE+
;
; The following jump to the initialisation code also provides three bytes
; of storage, two of which are used later by the resident part of the code.
;
BEGIN: JMP INIT ; jump to initialisation code
;
; Redefine storage for the above jump
;
ORG BEGIN
MBIT EQU THIS BYTE ; Make/Break bit
ORG BEGIN+1
ONOFF EQU THIS BYTE ; On/Off flag (0=off, initially on)
;
; Back to normal storage allocation
;
ORG BEGIN+3
;
; The following three values may be changed if required. MPID is the multiplex
; ID, and will only need alteration if some other TSR is using the same value.
; Choose another at random until it works! NEWKEY is the scan code value for
; the key to replace NUM LOCK. MODE is used to force a particular operation
; mode; it is particularly useful when a BIOS says that it supports the
; keyboard intercept function, but doesn't.
;
MPID DB 09FH ; 102H Multiplex ID ** DO NOT MOVE **
NEWKEY DB 03BH ; 103H Replacement key ** DO NOT MOVE **
MODE DB 0 ; 104H Mode selector ** DO NOT MOVE **
; 00H = auto
; 01H = use INT 15H
; 02H = use INT 09H
;
INTOFF DW ? ; Old interrupt vector offset
INTSEG DW ? ; Old interrupt vector segment
I2FOFF DW ? ; Old INT 2FH offset
I2FSEG DW ? ; Old INT 2FH segment
;
SUBTTL INT 2FH (multiplex) handler
PAGE+
;
; This INT 2FH handler is hooked into the MS-DOS multiplex interrupt.
;
; Input parameters:
;
; AH = handler ID (MPID for this program)
; Calls with unrecognised handler IDs are passed on
; AL = function code
; 00 - get installation status
; 01 - get GOLD status
; 02 - set GOLD status
;
; Output parameters:
;
; AL = result
; Get installation status:
; FFH - Already installed
; Get GOLD status:
; 00H - OFF
; 01H - ON
; Set GOLD status:
; 00H - OK
;
I2FHAN PROC FAR
;
ASSUME CS:CSEG,DS:NOTHING,ES:NOTHING,SS:NOTHING
;
CMP AH,MPID ; for this program?
JE I2FH10 ; j if so
JMP DWORD PTR I2FOFF ; else use old handler
;
I2FH10: OR AL,AL ; AL=0, get installation status?
JNE I2FH20 ; j if not
MOV AL,0FFH ; indicate already installed
IRET ; and return
;
I2FH20: DEC AL ; AL=1, get GOLD status?
JNE I2FH30 ; j if not
MOV AL,ONOFF ; get value
IRET ; and return
;
I2FH30: DEC AL ; AL=2, set GOLD status?
JNE I2FH40 ; j if not
MOV ONOFF,DL ; set new value, drop through
;
I2FH40: IRET ; and return
;
I2FHAN ENDP
;
SUBTTL INT 15H (system services) handler
PAGE+
;
; This INT 15H handler is hooked into the BIOS system services interrupt.
; It is used only if the keyboard interrupt intercept capability is available
; in the BIOS.
;
; Input parameters:
; AH - function. Only 4FH (keyboard intercept) is handled;
; other values cause the action to be passed to the
; previous handler.
; AL - scan code for key just pressed
;
; Output parameters:
; AL - input scan code, or mapped version of it.
; CY - set to indicate that keystroke is to be processed.
; All other register contents are preserved.
;
ASSUME CS:CSEG,DS:NOTHING,ES:NOTHING,SS:NOTHING
;
I15HAN PROC FAR
;
CMP AH,4FH ; keyboard intercept function?
JE I15H10 ; j if so
JMP DWORD PTR INTOFF ; else call old handler
;
I15H10: PUSH AX ; save register
MOV AH,AL ; copy scan code
AND AH,80H ; isolate make/break bit
MOV MBIT,AH ; save it
AND AL,7FH ; mask out make/break bit
CMP AL,45H ; NUM LOCK?
JNE I15H60 ; j if not - just return
;
; NUM LOCK has been pressed. Check for SHIFT (retain normal action).
;
PUSH DS ; save segment
MOV AX,40H ; BIOS data segment
MOV DS,AX ; address BIOS data segment
MOV AL,DS:[17H] ; get keyboard flags
POP DS ; recover segment
AND AL,0FH ; mask out lock status
MOV AH,AL ; take copy for later comparison
CMP ONOFF,0 ; is GOLD on?
JE I15H20 ; j if not - do nothing here
AND AL,03H ; mask out ALT and CTRL status
JE I15H20 ; j if not shifted
CMP AH,AL ; see if just SHIFT
JE I15H60 ; if so, treat as normal NUM LOCK call
;
; Check for ALT (invert GOLD status). This needs to work whether GOLD is
; ON or OFF.
;
I15H20: MOV AL,AH ; recover shift status bits
AND AL,08H ; mask out CTRL and SHIFT status
JE I15H40 ; j if not ALT - pass through
CMP AH,AL ; see if just ALT
JNE I15H40 ; j if not - pass through
TEST MBIT,80H ; make operation?
JNE I15H30 ; j if not - ignore
XOR ONOFF,1 ; flip GOLD ON/OFF flag
;
I15H30: CLC ; absorb keystroke
POP AX ; recover register
RETF 2 ; return, preserving flags
;
I15H40: CMP ONOFF,0 ; is GOLD on?
JE I15H60 ; j if not - do nothing
;
I15H50: POP AX ; recover register
MOV AL,NEWKEY ; set replacement scan code
OR AL,MBIT ; include make/break bit, drop through
STC ; make sure keystroke processed
RETF 2 ; return, preserving flags
;
I15H60: STC ; make sure keystroke processed
POP AX ; recover register
RETF 2 ; return, preserving flags
;
I15HAN ENDP
;
I15LEN = $ - I15HAN ; length of INT 15H handler
;
SUBTTL INT 09H (keyboard interrupt) handler
PAGE+
;
; This INT 09H handler is hooked into the keyboard interrupt vector.
; It is used only if the keyboard interrupt intercept facility is not
; available in the BIOS, and is moved in memory so that the space occupied
; by the INT 15H handler is not wasted.
;
; Input parameters:
; No explicit inputs. Implicit input from the keyboard
; hardware.
;
; Output parameters:
; No explicit outputs. Control is passed to the normal keyboard
; interrupt handler unless the keystroke is to be modified or
; absorbed. Modified keystrokes are placed into the BIOS input
; buffer.
; All registers are preserved.
;
I09HAN PROC FAR
;
PUSH AX ; save register
IN AL,60H ; get next character from hardware
MOV AH,AL ; copy scan code
AND AH,80H ; isolate make/break bit
MOV MBIT,AH ; save it
AND AL,7FH ; mask out make/break bit
CMP AL,45H ; NUM LOCK?
JE I09H10 ; j if so
JMP I09H80 ; else just pass on to original handler
;
; NUM LOCK has been pressed. Check for SHIFT (retain normal action).
;
I09H10: PUSH DS ; save segment
MOV AX,40H ; BIOS data segment
MOV DS,AX ; address BIOS data segment
MOV AL,DS:[17H] ; get keyboard flags
POP DS ; recover segment
AND AL,0FH ; mask out lock status
MOV AH,AL ; take copy for later comparison
CMP ONOFF,0 ; is GOLD on?
JE I09H20 ; j if not - do nothing here
AND AL,03H ; mask out ALT and CTRL status
JE I09H20 ; j if not shifted
CMP AH,A